package de.uni_mannheim.informatik.ai.dame_ai.main.ui;

import java.util.Map;
import java.util.Set;

import de.uni_mannheim.informatik.ai.dame_ai.util.CsvAccess;
import de.uni_mannheim.informatik.ai.dame_ai.util.FileSystem;

public class MainMenuDictionary {
	private static Map<String, Map<String, String>> langs;
	static{
		langs = CsvAccess.getLangs(FileSystem.GameName.main);
	}

	private Map<String, String> lang;
	private String name;
	
	private MainMenuDictionary(Map<String, String> lang, String name){
		this.lang = lang;
		this.name = name;
	}
	public static MainMenuDictionary getDictionary(int language){
		if(language == 0)
			return getDefaultDictionary();
		else{
		String langName = null;
		switch(language){
			case 1: langName = "Deutsch";
		}
		Map<String, String> lang = null;
		MainMenuDictionary dict = null;
		if(langs.containsKey(langName))
			lang = langs.get(langName);
		if(lang != null)
			dict = new MainMenuDictionary(lang, langName);
		return dict;
		}
	}
	public static MainMenuDictionary getDictionary(String language){
		if(language.equals("English"))
			return getDefaultDictionary();
		Map<String, String> lang = null;
		MainMenuDictionary dict = null;
		if(langs.containsKey(language))
			lang = langs.get(language);
		if(lang != null)
			dict = new MainMenuDictionary(lang, language);
		return dict;
	}

	public static Set<String> getAvailableLangs(){
		return langs.keySet();
	}
	public static MainMenuDictionary getDefaultDictionary(){
		return new MainMenuDictionary(null, "English");
	}
	public boolean containsLanguage(String lang){
		if(langs.containsKey(lang))
			return true;
		else
			return false;
	}
	
	public String translate(Phrases phrase){
		String translation=null;
		if( lang!=null )
			translation = lang.get(phrase.name());
		if ( translation == null )
			translation = phrase.toString();
		return translation;
	}
	
	public enum Phrases{
		main_language("Language"),
		main_gameName_battleship("Battleship"),
		main_gameName_dame("Dame"),
		main_gameName_mill("Mill"),
		main_gameName_mensch("Mensch aergere dich nicht"),
		main_playGame_battleship("Play Battleship"),
		main_playGame_dame("Play Dame"),
		main_playGame_mill("Play Mill"),
		main_playGame_mensch("Play Mensch aergere dich nicht"),
		main_gameInfo_battleship("is a guessing game played by two people."),
		main_gameInfo_dame("is a strategy board games between two players which involve diagonal moves of uniform pieces and mandatory captures by jumping over the enemy's pieces."),
		main_gameInfo_mill("Each player has nine pieces, or 'men', which move among the board's twenty-four intersections. The object of the game is to leave the opposing player with fewer than three pieces or, as in checkers, no legal moves."),
		main_gameInfo_mensch("The game can be played by 2, 3 or 4 players - one player per board side. Each player has 4 game pieces, which are in the 'out' area when the game starts, and which must be brought into the player's 'home' row. Early games had painted wooden pieces."),
		main_quickStart("Quick start"),
		main_new("New Game"),
		main_load("Load Game"),
		main_replay("Replay Game"),
		main_return("Return"),
		main_ok("OK"),
		main_number("Nr"),
		main_name("Name"),
		main_human("is human player"),
		main_cancel("Cancel"),
		main_loadMessage("Please choose one of the following files you wish to load."),
		main_error("Error"),
		main_noHuman("At least one human player is needed!");

		private String inEnglish;
		Phrases(String english){
			this.inEnglish = english;
		}
		
		@Override
		public String toString(){
			return inEnglish;
		}
	}
	public String getLanguageName(){
		return name;
	}
}
